package com.zygh.policeasset.mapper;

import com.zygh.policeasset.pojo.AuditFlow;
import com.zygh.policeasset.pojo.vo.AuditFlowTODoVO;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/mapper/AuditFlowMapper.class */
public interface AuditFlowMapper {
    @Results(id = "map", value = {@Result(property = "flowNo", column = "flow_no"),
            @Result(property = "tableType", column = "table_type"),
            @Result(property = "createTime", column = "create_time"),
            @Result(property = "approvalStepsId", column = "approval_steps_id"),
            @Result(property = "appStatus", column = "app_status")})
    @Select({"select af.*,u.name as applicantName  from audit_flow af left join user u on af.applicant = u.id where af.id = #{id}"})
    AuditFlow queryById(Integer num);

    @Select({"select id from ${tableType} where flow_no = #{flowNo}"})
    Integer queryIdByflowNo(String tableType, String flowNo);

    @ResultMap({"map"})
    @Select({"<script>select * from audit_flow <where> <if test='id != null '>id=#{id} </if><if test='flowNo != null and flowNo.length &gt; 0'>flow_no=#{flowNo} </if><if test='tableType != null and tableType.length &gt; 0'>table_type=#{tableType} </if><if test='applicant != null '>applicant=#{applicant} </if><if test='appStatus != null '>app_status=#{appStatus} </if></where> </script>"})
    List<AuditFlow> queryAll(AuditFlow auditFlow);

    @Insert({"insert into audit_flow(flow_no,title,table_type,applicant,create_time,app_status,project_no,section_id) " +
            "values(#{flowNo},#{title},#{tableType},#{applicant},#{createTime},#{appStatus},#{projectNo},#{sectionId})"})
    int insert(AuditFlow auditFlow);

    @Insert({"insert into audit_flow(flow_no,title,table_type,applicant,create_time,app_status,project_no,section_id,approval_steps_id) " +
            "values(#{flowNo},#{title},#{tableType},#{applicant},#{createTime},#{appStatus},#{projectNo},#{sectionId},#{approvalStepsId})"})
    int insertYouKe(AuditFlow auditFlow);

    @Update({"<script>update audit_flow <set><if test='flowNo != null and flowNo.length &gt; 0'> flow_no=#{flowNo},</if><if test='title != null and title.length &gt; 0'> title=#{title},</if><if test='tableType != null and tableType.length &gt; 0'> table_type=#{tableType},</if><if test='applicant != null '> applicant=#{applicant},</if><if test='appStatus != null'> app_status=#{appStatus},</if><if test='createTime != null and createTime.length &gt; 0'> create_time=#{createTime},</if></set> where id = #{id}</script>"})
    int update(AuditFlow auditFlow);

    @Delete({"delete from audit_flow where id = #{id}"})
    int deleteById(Integer id);

    @Update({"<script>update audit_flow <set><if test='appStatus != null '> app_status=#{appStatus},</if>" +
            "<if test='createTime != null and createTime.length &gt; 0'> create_time=#{createTime},</if>" +
            "<if test='approvalStepsId != null'> approval_steps_id=#{approvalStepsId},</if>" +
            "</set> where flow_no = #{flowNo} </script>"})
    int updateAppStatus(AuditFlow auditFlow);

    @Results({@Result(property = "flowNo", column = "flow_no"), @Result(property = "id", column = "id"), @Result(property = "tableType", column = "table_type"), @Result(property = "createTime", column = "create_time"), @Result(property = "appStatus", column = "app_status"), @Result(property = "projectNo", column = "project_no"), @Result(property = "sectionId", column = "section_id")})
    @Select({"<script>select af.id,af.flow_no,af.approval_steps_id as approvalStepsId,af.title,af.table_type,af.applicant,af.create_time,af.project_no,af.section_id,u.name as applicantName,afd.audit_status as app_status  from audit_flow af left join `user` u on af.applicant = u.id  LEFT JOIN audit_flow_detail afd ON af.flow_no = afd.flow_no <where> <if test='userId != null and status != 0 '>and afd.reviewer=#{userId} </if><if test='userId != null and status == 0 '>and af.applicant=#{userId} </if><if test='status != 0 '>and audit_status=#{status} </if><if test='tableType != null and tableType.length &gt; 0'>and table_type=#{tableType}</if><if test='applicant != null'>and af.applicant=#{applicant} </if></where> order by af.create_time desc</script>"})
    List<AuditFlowTODoVO> queryAudit(@Param("userId") Integer num, @Param("status") Integer num2, @Param("tableType") String str, @Param("applicant") Integer num3);

    @Select({"<script>select count(*) from audit_flow af left join audit_flow_detail afd on af.flow_no = afd.flow_no left join user u on af.applicant = u.id <where> <if test='userId != null and status != 0 '>and afd.reviewer=#{userId} </if><if test='status != 0 '>and audit_status=#{status} </if></where> order by af.create_time desc</script>"})
    Integer queryAuditCount(@Param("userId") Integer num, @Param("status") Integer num2);
}